package com.example.demo.Utils.Result;

import java.io.Serial;
import java.util.HashMap;
import java.util.Map;

public class R extends HashMap<String, Object> {
    public interface HttpStatus {
        int SC_CONTINUE = 100;
        int SC_SWITCHING_PROTOCOLS = 101;
        int SC_PROCESSING = 102;
        int SC_OK = 200;
        int SC_CREATED = 201;
        int SC_ACCEPTED = 202;
        int SC_NON_AUTHORITATIVE_INFORMATION = 203;
        int SC_NO_CONTENT = 204;
        int SC_RESET_CONTENT = 205;
        int SC_PARTIAL_CONTENT = 206;
        int SC_MULTI_STATUS = 207;
        int SC_MULTIPLE_CHOICES = 300;
        int SC_MOVED_PERMANENTLY = 301;
        int SC_MOVED_TEMPORARILY = 302;
        int SC_SEE_OTHER = 303;
        int SC_NOT_MODIFIED = 304;
        int SC_USE_PROXY = 305;
        int SC_TEMPORARY_REDIRECT = 307;
        int SC_BAD_REQUEST = 400;
        int SC_UNAUTHORIZED = 401;
        int SC_PAYMENT_REQUIRED = 402;
        int SC_FORBIDDEN = 403;
        int SC_NOT_FOUND = 404;
        int SC_METHOD_NOT_ALLOWED = 405;
        int SC_NOT_ACCEPTABLE = 406;
        int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
        int SC_REQUEST_TIMEOUT = 408;
        int SC_CONFLICT = 409;
        int SC_GONE = 410;
        int SC_LENGTH_REQUIRED = 411;
        int SC_PRECONDITION_FAILED = 412;
        int SC_REQUEST_TOO_LONG = 413;
        int SC_REQUEST_URI_TOO_LONG = 414;
        int SC_UNSUPPORTED_MEDIA_TYPE = 415;
        int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
        int SC_EXPECTATION_FAILED = 417;
        int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419;
        int SC_METHOD_FAILURE = 420;
        int SC_UNPROCESSABLE_ENTITY = 422;
        int SC_LOCKED = 423;
        int SC_FAILED_DEPENDENCY = 424;
        int SC_INTERNAL_SERVER_ERROR = 500;
        int SC_NOT_IMPLEMENTED = 501;
        int SC_BAD_GATEWAY = 502;
        int SC_SERVICE_UNAVAILABLE = 503;
        int SC_GATEWAY_TIMEOUT = 504;
        int SC_HTTP_VERSION_NOT_SUPPORTED = 505;
        int SC_INSUFFICIENT_STORAGE = 507;
    }


    @Serial
    private static final long serialVersionUID = 1L;

    public R() {

    }

    public static R error() {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }

    public static R error(String msg) {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
    }

    public static R error(int code, String msg) {
        R r = new R();
        r.put("code", code);
        r.put("msg", msg);
        return r;
    }

    public static R ok(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_OK);
        r.put("msg", msg);
        return r;
    }

    public static R ok(Map<String, Object> map) {
        R r = new R();
        r.putAll(map);
        return r;
    }

    public static R ok() {
        R r = new R();
        r.put("code", HttpStatus.SC_OK);
        r.put("msg","完全莫得问题");
        return r;
    }
    public static R created(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_CREATED);
        r.put("msg", msg);
        return r;
    }

    public static R accepted(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_ACCEPTED);
        r.put("msg", msg);
        return r;
    }

    public static R noContent() {
        R r = new R();
        r.put("code", HttpStatus.SC_NO_CONTENT);
        r.put("msg", "无内容");
        return r;
    }

    public static R partialContent() {
        R r = new R();
        r.put("code", HttpStatus.SC_PARTIAL_CONTENT);
        r.put("msg", "部分内容");
        return r;
    }

    public static R multipleChoices(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_MULTIPLE_CHOICES);
        r.put("msg", msg);
        return r;
    }

    public static R movedPermanently(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_MOVED_PERMANENTLY);
        r.put("msg", msg);
        return r;
    }

    public static R movedTemporarily(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_MOVED_TEMPORARILY);
        r.put("msg", msg);
        return r;
    }

    public static R seeOther(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_SEE_OTHER);
        r.put("msg", msg);
        return r;
    }

    public static R notModified() {
        R r = new R();
        r.put("code", HttpStatus.SC_NOT_MODIFIED);
        r.put("msg", "未修改");
        return r;
    }

    public static R useProxy(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_USE_PROXY);
        r.put("msg", msg);
        return r;
    }

    public static R temporaryRedirect(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_TEMPORARY_REDIRECT);
        r.put("msg", msg);
        return r;
    }

    public static R badRequest(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_BAD_REQUEST);
        r.put("msg", msg);
        return r;
    }

    public static R unauthorized(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_UNAUTHORIZED);
        r.put("msg", msg);
        return r;
    }

    public static R paymentRequired(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_PAYMENT_REQUIRED);
        r.put("msg", msg);
        return r;
    }

    public static R forbidden(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_FORBIDDEN);
        r.put("msg", msg);
        return r;
    }

    public static R notFound(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_NOT_FOUND);
        r.put("msg", msg);
        return r;
    }

    public static R methodNotAllowed(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_METHOD_NOT_ALLOWED);
        r.put("msg", msg);
        return r;
    }

    public static R notAcceptable(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_NOT_ACCEPTABLE);
        r.put("msg", msg);
        return r;
    }

    public static R proxyAuthenticationRequired(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
        r.put("msg", msg);
        return r;
    }

    public static R requestTimeout(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_REQUEST_TIMEOUT);
        r.put("msg", msg);
        return r;
    }

    public static R conflict(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_CONFLICT);
        r.put("msg", msg);
        return r;
    }

    public static R gone(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_GONE);
        r.put("msg", msg);
        return r;
    }

    public static R lengthRequired(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_LENGTH_REQUIRED);
        r.put("msg", msg);
        return r;
    }

    public static R preconditionFailed(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_PRECONDITION_FAILED);
        r.put("msg", msg);
        return r;
    }

    public static R requestTooLong(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_REQUEST_TOO_LONG);
        r.put("msg", msg);
        return r;
    }

    public static R requestUriTooLong(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_REQUEST_URI_TOO_LONG);
        r.put("msg", msg);
        return r;
    }

    public static R unsupportedMediaType(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE);
        r.put("msg", msg);
        return r;
    }

    public static R requestedRangeNotSatisfiable(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
        r.put("msg", msg);
        return r;
    }

    public static R expectationFailed(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_EXPECTATION_FAILED);
        r.put("msg", msg);
        return r;
    }

    public static R insufficientSpaceOnResource(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE);
        r.put("msg", msg);
        return r;
    }

    public static R methodFailure(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_METHOD_FAILURE);
        r.put("msg", msg);
        return r;
    }

    public static R unprocessableEntity(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_UNPROCESSABLE_ENTITY);
        r.put("msg", msg);
        return r;
    }

    public static R locked(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_LOCKED);
        r.put("msg", msg);
        return r;
    }

    public static R failedDependency(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_FAILED_DEPENDENCY);
        r.put("msg", msg);
        return r;
    }

    public static R notImplemented(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_NOT_IMPLEMENTED);
        r.put("msg", msg);
        return r;
    }

    public static R badGateway(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_BAD_GATEWAY);
        r.put("msg", msg);
        return r;
    }

    public static R serviceUnavailable(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_SERVICE_UNAVAILABLE);
        r.put("msg", msg);
        return r;
    }

    public static R gatewayTimeout(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_GATEWAY_TIMEOUT);
        r.put("msg", msg);
        return r;
    }

    public static R httpVersionNotSupported(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED);
        r.put("msg", msg);
        return r;
    }

    public static R insufficientStorage(String msg) {
        R r = new R();
        r.put("code", HttpStatus.SC_INSUFFICIENT_STORAGE);
        r.put("msg", msg);
        return r;
    }

    public R put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
